#include <option_parser.h>

#include <iostream>

int main(int32_t argc, const char **argv)
{
    int32_t arg1 = 0;
    int64_t arg2 = 0;
    double arg3 = 0;
    std::string arg4 = "";

    int32_t i321 = 0;
    int32_t i322 = 0;
    int32_t i323 = 0;

    int64_t i641 = 0;
    int64_t i642 = 0;
    int64_t i643 = 0;

    double f641 = 0;
    double f642 = 0;
    double f643 = 0;

    std::string str1 = "";
    std::string str2 = "";
    std::string str3 = "";

    bool b1 = false;
    bool b2 = true;
    bool b3 = false;

    OptionParser parser;
    parser.AddArguments(arg1);
    parser.AddArguments(arg2);
    parser.AddArguments(arg3);
    parser.AddArguments(arg4);

    parser.AddOption("a", "aa", i321);
    parser.AddOption("b", "bb", i322);
    parser.AddOption("c", "cc", i323);
    parser.AddOption("d", "dd", i641);
    parser.AddOption("e", "ee", i642);
    parser.AddOption("f", "ff", i643);
    parser.AddOption("g", "gg", f641);
    parser.AddOption("h", "hh", f642);
    parser.AddOption("i", "ii", f643);
    parser.AddOption("j", "jj", str1);
    parser.AddOption("k", "kk", str2);
    parser.AddOption("l", "ll", str3);
    parser.AddOption("m", "mm", b1);
    parser.AddOption("n", "nn", b2);
    parser.AddOption("o", "oo", b3);

    const char *args[] = {
        "1", "2", "3", "4",
        "-a", "1", "--bb", "2", "--cc=3",
        "-d", "1", "--ee", "2", "--ff=3",
        "-g", "1.5", "--hh", "2.5", "--ii=3.5",
        "-j", "j", "--kk", "kk", "--ll=ll",
        "-m", "--nn", "--oo",
        "a", "b", "c",
        "1", "2", "3",
        "--display=1",
        "-z", "1",
        "--zz", "1",
    };
    if (parser.Parse(sizeof(args) / sizeof(*args), args)) {
        std::cerr << "failed: " << parser.GetErrorString() << std::endl;
        return 1;
    }

    std::cout << std::boolalpha;
    std::cout << "i321: " << i321 << std::endl;
    std::cout << "i322: " << i322 << std::endl;
    std::cout << "i323: " << i323 << std::endl;
    std::cout << "i641: " << i641 << std::endl;
    std::cout << "i642: " << i642 << std::endl;
    std::cout << "i643: " << i643 << std::endl;
    std::cout << "f641: " << f641 << std::endl;
    std::cout << "f642: " << f642 << std::endl;
    std::cout << "f643: " << f643 << std::endl;
    std::cout << "str1: " << str1 << std::endl;
    std::cout << "str2: " << str2 << std::endl;
    std::cout << "str3: " << str3 << std::endl;
    std::cout << "b1: " << b1 << std::endl;
    std::cout << "b2: " << b2 << std::endl;
    std::cout << "b3: " << b3 << std::endl;

    std::cout << "skipped " << parser.GetSkippedArgc() << std::endl;
    for (int32_t i = 0; i < parser.GetSkippedArgc(); i++) {
        std::cout << "skipped: " << parser.GetSkippedArgv()[i] << std::endl;
    }

    std::string str4 = "";
    OptionParser parser2;
    parser2.AddArguments(str4);
    parser2.Parse(parser.GetSkippedArgc(), parser.GetSkippedArgv());
    std::cout << "reuse " << str4 << std::endl;

    std::cout << "skipped " << parser2.GetSkippedArgc() << std::endl;
    for (int32_t i = 0; i < parser2.GetSkippedArgc(); i++) {
        std::cout << "skipped: " << parser2.GetSkippedArgv()[i] << std::endl;
    }
    return 0;
}
